/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package im.general;

import jade.core.behaviours.Behaviour;
import java.util.Iterator;
import java.util.Vector;

/**
 *
 * @author brownstone
 */
public class TypeBehavioursHandler {

    protected class TypeToBehaviour {
        private int type;
        private Behaviour bh;
        public TypeToBehaviour(int type, Behaviour bh) {
            this.type = type;
            this.bh = bh;
        }
        public int getType() {
            return type;
        }
        public Behaviour getBehaviour() {
            return bh;
        }
    };

    Vector<TypeToBehaviour> associations;

    public TypeBehavioursHandler() {
        associations = new Vector();
    }

    public void addAssociation(int type, Behaviour bh) {
        associations.add(new TypeToBehaviour(type, bh));
    }

    public Behaviour getBehaviour(int type) {
        Iterator i = associations.iterator();

        for(TypeToBehaviour ttb = (TypeToBehaviour)i.next();
        i.hasNext() ;
        ttb = (TypeToBehaviour)i.next()) {
            if(ttb.getType()==type)
                return ttb.getBehaviour();
        }
        return null;
    }
}
